<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<ul id="list">
			<li>1</li>
			<li id="d2">2</li>
			<li>3</li>
			<li>4</li> 
		</ul>
		<script>
			var news = document.createElement("li");
			news.innerHTML = "A";
			list.appendChild(news);
			
			var news2 = document.createElement("li");
			news2.innerHTML = "B";
			list.insertBefore(news2,d2);
		</script>
	</body>
</html>
